package com.captjack.micro.service.message;

import com.captjack.micro.common.entity.EmailMessageEntity;
import com.captjack.micro.common.entity.MessageQueueConstant;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Description description.....
 *
 * @author Jack Sparrow
 * @version 1.0.0
 * @date 2018/7/7 21:44
 * package com.captjack.micro.service.message
 */
@SpringBootApplication
@RestController
public class MessageMicroServiceApplication {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    @GetMapping("/")
    public String test() {
        EmailMessageEntity emailMessageEntity = new EmailMessageEntity();
        emailMessageEntity.setSubject("test");
        emailMessageEntity.setText("test");
        emailMessageEntity.setFrom("15321573503@163.com");
        emailMessageEntity.setTo("907198504@qq.com");
        rabbitTemplate.convertAndSend(MessageQueueConstant.EMAIL_MESSAGE_TOPIC, emailMessageEntity);
        return "send success";
    }

    public static void main(String[] args) {
        SpringApplication.run(MessageMicroServiceApplication.class, args);
    }

}
